<template>
  <div class="mod-config">
    <h2>供应商密码修改</h2>
    <el-form class="flex-box" :label-position="labelPosition"  :model="formLabelAlign">
      <el-form-item label="供应商编号:">
        {{supplier.supplierNum}}
      </el-form-item>
      <el-form-item label="供应商证书编号:">
        {{supplier.certificate}}
      </el-form-item>
      <el-form-item label="公司名称:">
        {{supplier.company}}
      </el-form-item>
      <el-form-item label="公司性质:">
        {{supplier.kind}}
      </el-form-item>
      <el-form-item label="联系人:">
        {{supplier.contact}}
      </el-form-item>
      <el-form-item label="电话:">
        {{supplier.phone}}
      </el-form-item>
      <el-form-item label="传真:">
        {{supplier.fax}}
      </el-form-item>
      <el-form-item label="电子邮件:">
        {{supplier.email}}
      </el-form-item>
      <el-form-item label="地址:">
        {{supplier.address}}
      </el-form-item>
      <el-form-item label="邮编:">
        {{supplier.zip}}
      </el-form-item>
      <el-form-item label="注册资金:">
        {{supplier.regFund}}
      </el-form-item>
      <el-form-item label="法人代表:">
        {{supplier.corporation}}
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
  import AddOrUpdate from './employee-add-or-update'
  export default {
    data () {
      return {
        dataForm: {
          key: ''
        },
        dataList: [],
        pageIndex: 1,
        pageSize: 10,
        totalPage: 0,
        dataListLoading: false,
        dataListSelections: [],
        addOrUpdateVisible: false,
        supplier:{},
        labelPosition: 'left',
        formLabelAlign: {
          name: '',
          region: '',
          type: ''
        },
      }
    },
    components: {
      AddOrUpdate
    },
    mounted () {
      this.getDataList()
    },
    methods: {
      // 获取数据列表
      getDataList () {
        this.dataListLoading = true
        this.$http({
          url: this.$http.adornUrl('/purchase/supplier/supplierDetail'),
          method: 'get',
        }).then((data) => {
          if (data && data.code === 200) {
            console.log(data.supplier)
            this.supplier = data.supplier
            console.log(this.supplier.address)
          } else {
            this.dataList = []
            this.totalPage = 0
            console.log("出错啦")
          }
          this.dataListLoading = false
        })
      },
      // 新增 / 修改
      addOrUpdateHandle (id) {
        this.addOrUpdateVisible = true
        this.$nextTick(() => {
          this.$refs.addOrUpdate.init(id)
        })
      },
      // 删除
      deleteHandle (id) {
        var ids = id ? [id] : this.dataListSelections.map(item => {
          return item.id
        })
        this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$http({
            url: this.$http.adornUrl('/purchase/employee/delete'),
            method: 'post',
            data: this.$http.adornData(ids, false)
          }).then(({data}) => {
            if (data && data.code === 0) {
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {
                  this.getDataList()
                }
              })
            } else {
              this.$message.error(data.msg)
            }
          })
        })
      }
    }
  }
</script>
<style lang="scss" scoped>
.flex-box,.el-form{
  //弹性布局
  display: flex;
  //flex-direction属性决定主轴的方向（即项目的排列方向）。
  flex-direction: row;
  //flex-wrap属性定义，如果一条轴线排不下，如何换行。
  //wrap：换行，第一行在上方。
  flex-wrap:  wrap;
  //align-content属性定义了多根轴线的对齐方式。
  //flex-start：与交叉轴的起点对齐。
  align-content: flex-start;
  //justify-content属性定义了项目在主轴上的对齐方式。
  //space-between：两端对齐，项目之间的间隔都相等。
  justify-content: space-between;
  .el-form-item{
    width: 200px;
  }
  *{
    margin-right: 80px;
    margin-left: 80px;
  }
}
</style>
